package com.entity.table;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;


/**
 * 订单表 表定义层。
 *
 * @author admin
 * @since 2024-05-31
 */
public class FOrderTableDef extends TableDef {

    private static final long serialVersionUID = 1L;

    /**
     * 订单表
     */
    public static final FOrderTableDef F_ORDER = new FOrderTableDef();

    /**
     * 索引
     */
    public final QueryColumn ID = new QueryColumn(this, "id");

    /**
     * 下单时间
     */
    public final QueryColumn TIME = new QueryColumn(this, "time");

    /**
     * 手机号
     */
    public final QueryColumn PHONE = new QueryColumn(this, "phone");

    /**
     * 订单状态
     */
    public final QueryColumn STATUS = new QueryColumn(this, "status");

    /**
     * 用户id
     */
    public final QueryColumn USER_ID = new QueryColumn(this, "user_id");

    /**
     * 收货地址
     */
    public final QueryColumn ADDRESS = new QueryColumn(this, "address");

    /**
     * 订单号
     */
    public final QueryColumn ORDER_NO = new QueryColumn(this, "order_no");

    /**
     * 购买用户
     */
    public final QueryColumn USER_NAME = new QueryColumn(this, "user_name");

    /**
     * 支付状态
     */
    public final QueryColumn PAY_STATUS = new QueryColumn(this, "pay_status");

    /**
     * 订单总价
     */
    public final QueryColumn TOTAL_PRICE = new QueryColumn(this, "total_price");

    /**
     * 所有字段。
     */
    public final QueryColumn ALL_COLUMNS = new QueryColumn(this, "*");

    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ID, ORDER_NO, STATUS, TIME, USER_NAME, PHONE, ADDRESS, TOTAL_PRICE, PAY_STATUS, USER_ID};

    public FOrderTableDef() {
        super("", "f_order");
    }

    private FOrderTableDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public FOrderTableDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new FOrderTableDef("", "f_order", alias));
    }

}
